<template>
  <a-card :bordered="false">
    <!-- table区域-begin -->
    <!-- <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleInfo(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div> -->
    <div class="cardBox">
      <a-card title="基站1" style="width: 45%">
        <a slot="extra" href="#" @click="handleInfo(1)">详情</a>
        <time-slot :statusList="statusList1" />
      </a-card>
      <a-card title="基站2" style="width: 45%">
        <a slot="extra" href="#" @click="handleInfo(2)">详情</a>
        <time-slot :statusList="statusList2" />
      </a-card>
      <a-card title="基站3" style="width: 45%">
        <a slot="extra" href="#" @click="handleInfo(3)">详情</a>
        <time-slot :statusList="statusList3" />
      </a-card>
      <a-card title="基站4" style="width: 45%">
        <a slot="extra" href="#" @click="handleInfo(4)">详情</a>
        <time-slot :statusList="statusList4" />
      </a-card>
    </div>

    <a-card title="上行链路配置" :bordered="false">
      <a-form-model title="上行链路配置" :model="form" :label-col="labelCol" :wrapper-col="wrapperCol">
        <a-form-model-item label="星指上行频点号">
          <a-select v-model="form.UplinkNo" placeholder="请选择">
            <a-select-option :key="index" v-for="(item, index) in UplinkList"> {{ item.label }} </a-select-option>
          </a-select>
        </a-form-model-item>
        <a-form-model-item label="星指下行频点号">
          <a-select v-model="form.DownlinkNo" placeholder="请选择">
            <a-select-option :key="index" v-for="(item, index) in DownlinkList"> {{ item.label }} </a-select-option>
          </a-select>
        </a-form-model-item>
        <a-form-model-item label="星弹下行速率挡位">
          <a-select v-model="form.DownstreamGear" placeholder="请选择">
            <a-select-option :key="index" v-for="(item, index) in DownstreamGearList">
              {{ item.label }}
            </a-select-option>
          </a-select> </a-form-model-item
        ><a-form-model-item :wrapper-col="{ span: 14, offset: 4 }">
          <a-button type="primary" @click="onSubmit"> 确定 </a-button>
          <a-button style="margin-left: 10px"> 取消 </a-button>
        </a-form-model-item>
      </a-form-model>
    </a-card>

    <base-station-modal ref="modalForm" @ok="modalFormOk"></base-station-modal>
  </a-card>
</template>

<script>
import timeSlot from '@/components/timeSlot'
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import baseStationModal from './modules/baseStationModal'

export default {
  name: 'baseStationList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    baseStationModal,
    timeSlot,
  },
  data() {
    return {
      description: '实装管理管理页面',
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        // {
        //   title: '删除标识',
        //   align: 'center',
        //   dataIndex: 'delFlag'
        // },
        {
          title: '基站名称',
          align: 'center',
          dataIndex: 'name',
        },
        // {
        //   title: '类型',
        //   align: 'center',
        //   dataIndex: 'type',
        // },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status',
        },
        {
          title: '上线时间',
          align: 'center',
          dataIndex: 'time',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      form: {},
      labelCol: { span: 4 },
      wrapperCol: { span: 14 },
      statusList1: [
        { status: 0 },
        { status: 2 },
        { status: 1 },
        { status: 1 },
        { status: 0 },
        { status: 2 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
      ],
      statusList2: [
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 0 },
        { status: 2 },
        { status: 1 },
        { status: 1 },
        { status: 0 },
        { status: 2 },
      ],

      statusList3: [
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 0 },
        { status: 2 },
        { status: 1 },
        { status: 1 },
        { status: 0 },
        { status: 2 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
      ],
      statusList4: [
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 0 },
        { status: 2 },
        { status: 1 },
        { status: 1 },
        { status: 0 },
        { status: 2 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
        { status: 3 },
      ],
      url: {
        list: '/hardware/baseStation/list',
        delete: '/hardware/baseStation/delete',
        deleteBatch: '/hardware/baseStation/deleteBatch',
        exportXlsUrl: '/hardware/baseStation/exportXls',
        importExcelUrl: 'hardware/baseStation/importExcel',
      },
      dictOptions: {},
      superFieldList: [],
      dataSource: [
        { name: '基站1', time: '2020-10-05', status: '正常', type: '宏基站' },
        { name: '基站2', time: '2020-10-05', status: '正常', type: '分布式基站' },
        { name: '基站3', time: '2020-10-05', status: '非正常', type: '分布式基站' },
        { name: '基站4', time: '2020-10-05', status: '正常', type: '宏基站' },
      ],
      DownlinkList: [
        { label: '890MHz', value: '890MHz' },
        { label: '890.2MHz', value: '890.2MHz' },
        { label: '890.4MHz', value: '890.4MHz' },
        { label: '890.6MHz', value: '890.6MHz' },
      ],
      DownstreamGearList: [
        { label: '1', value: '1' },
        { label: '2', value: '2' },
        { label: '3', value: '3' },
        { label: '4', value: '4' },
      ],
      UplinkList: [
        { label: '890MHz', value: '890MHz' },
        { label: '890.2MHz', value: '890.2MHz' },
        { label: '890.4MHz', value: '890.4MHz' },
        { label: '890.6MHz', value: '890.6MHz' },
      ],
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    onSubmit() {
      console.log('submit!', this.form)
    },
    handleOk(e) {
      this.ModalText = 'The modal will be closed after two seconds'
      this.confirmLoading = true
      setTimeout(() => {
        this.visible = false
        this.confirmLoading = false
      }, 2000)
    },
    handleCancel(e) {
      console.log('Clicked cancel button')
      this.visible = false
    },
    handleInfo(type) {
      let data
      if (type == 1) data = JSON.stringify(this.statusList1)
      if (type == 2) data = JSON.stringify(this.statusList2)
      if (type == 3) data = JSON.stringify(this.statusList3)
      if (type == 4) data = JSON.stringify(this.statusList4)
      console.log(data)
      this.$router.push({
        name: 'baseStationChannel-baseStationInfo',
        query: { data },
      })
    },
    loadData() {
      // this.dataSource = [{}]
    },
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      // fieldList.push({ type: 'int', value: 'delFlag', text: '删除标识', dictCode: '' })
      // fieldList.push({ type: 'string', value: 'ip', text: 'ip', dictCode: '' })
      // fieldList.push({ type: 'string', value: 'type', text: '类型', dictCode: '' })
      // fieldList.push({ type: 'string', value: 'sysNo', text: '系统号', dictCode: '' })
      this.superFieldList = fieldList
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
.cardBox {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
}
</style>
